package cate.common.table.dynins;


import cate.common.table.ERow;
import cate.common.table.XSSFRowWrap;
import cate.common.table.d.GDHero;
import cp.solution.util.str.Str;
import easy.java.dev.note.NoteClass;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

@NoteClass("手办映射")
public class DynFurnitureRow extends ERow {

    private String j1AttrStr;
    private String j2AttrStr;
    private String j3AttrStr;
    private String j4AttrStr;


    private String j1SkillStr;
    private String j2SkillStr;
    private String j3SkillStr;
    private String j4SkillStr;

    @Override
    public void parse(XSSFRowWrap xrw) {
        super.parse(xrw);
        this.id = xrw.getInteger("强度等级", -1);
        this.j1AttrStr = xrw.getString("战士属性");
        this.j2AttrStr = xrw.getString("法师属性");
        this.j3AttrStr = xrw.getString("坦克属性");
        this.j4AttrStr = xrw.getString("辅助属性");

        this.j1SkillStr = xrw.getString("战士技能");
        this.j2SkillStr = xrw.getString("法师技能");
        this.j3SkillStr = xrw.getString("坦克技能");
        this.j4SkillStr = xrw.getString("辅助技能");
    }

    private List<Integer> j1Skills;
    private List<Integer> j2Skills;
    private List<Integer> j3Skills;
    private List<Integer> j4Skills;

    @Override
    public void decode() {
        if (StringUtils.isNotBlank(j1SkillStr)) {
            j1Skills = Str.strArr2intList(j1SkillStr.split("#"));
        }
        if (StringUtils.isNotBlank(j2SkillStr)) {
            j2Skills = Str.strArr2intList(j2SkillStr.split("#"));
        }
        if (StringUtils.isNotBlank(j3SkillStr)) {
            j3Skills = Str.strArr2intList(j3SkillStr.split("#"));
        }
        if (StringUtils.isNotBlank(j4SkillStr)) {
            j4Skills = Str.strArr2intList(j4SkillStr.split("#"));
        }
    }

    public String getAttrStr(byte job) {
        switch (job) {
            case GDHero.Job.J1:
                return j1AttrStr;
            case GDHero.Job.J2:
                return j2AttrStr;
            case GDHero.Job.J3:
                return j3AttrStr;
            case GDHero.Job.J4:
                return j4AttrStr;
            default:
                return null;
        }
    }

    public List<Integer> getSkills(byte job) {
        switch (job) {
            case GDHero.Job.J1:
                return j1Skills;
            case GDHero.Job.J2:
                return j2Skills;
            case GDHero.Job.J3:
                return j3Skills;
            case GDHero.Job.J4:
                return j4Skills;
            default:
                return null;
        }
    }


}
